<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>修改页面</title>
		<link rel="stylesheet" href="/new/component/pear/css/pear.css" />
		<script src="/js/jquery-2.2.4.js" type="text/javascript"></script>
	</head>
	<body>
		<form class="layui-form" id="ifrom">
			<div class="mainBox">
				<div class="main-container">
					<div class="layui-form-item">
						<label class="layui-form-label">账号</label>
						<div class="layui-input-block">
							<input type="hidden" name="user_id" id="user_id"  autocomplete="off" placeholder="请输入标题" class="layui-input">
							<input type="text" name="user_account" id="user_account" lay-verify="title" autocomplete="off"
								placeholder="请输入标题" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">密码</label>
						<div class="layui-input-block">
							<input type="text" name="user_password" id="user_password" lay-verify="title" autocomplete="off" placeholder="请输入标题"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<input type="text" name="user_remark" id="user_remark"  lay-verify="title"
								autocomplete="off" placeholder="请输入标题" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">序号</label>
						<div class="layui-input-block">
							<input type="text" name="user_idcard" id="user_idcard"  lay-verify="title" autocomplete="off"
								placeholder="请输入标题" class="layui-input">
						</div>
					</div>



				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="btn">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="/new/component/layui/layui.js"></script>
		<script src="/new/component/pear/pear.js"></script>
		<script>
			//获取父页面的全局变量users
			let user = parent.window.user;
			alert(user)
			$("#user_id").val(user.user_id);
			$("#user_account").val(user.user_account);
			$("#user_password").val(user.user_password);
			$("#user_remark").val(user.user_remark);
			$("#user_idcard").val(user.user_idcard);

			$("#btn").click(function(){

				$.ajax({
					async:false,//同步
					url:'/user/upd',//提交地址
					type:'post',//提交方式
					data:$("#ifrom").serialize(),//表单序列化
					dataType:'json',//转换数据类型
					success:function(data){//成功之后返回的数据
						if (data.code=='1'){
							alert("修改成功");
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭
							parent.location.reload();
						}else {
							alert("修改失败")
						}
					}
				})
			});
		</script>
	</body>
</html>
